package exam.test4;

import thread.PeopleThread;

import java.util.*;
import java.util.concurrent.FutureTask;

public class Test4 {
    public static void main(String[] args) throws Exception{
        Random r = new Random();

        List<Integer> moneys = new ArrayList<>();
        for (int i = 0; i < 40; i++) {
            moneys.add(r.nextInt(70) + 31);
        }
        for (int i = 0; i < 160; i++) {
            moneys.add(r.nextInt(30) + 1);
        }
        Collections.shuffle(moneys);
        System.out.println(moneys);

        List<FutureTask> futureTasks = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            PeopleThread peopleThread = new PeopleThread(moneys, i + "号");
            FutureTask<Integer> futureTask = new FutureTask<>(peopleThread);
            futureTasks.add(futureTask);
            Thread thread = new Thread(futureTask);
            thread.start();
        }
        List<Integer> total = new ArrayList<>();
        for (FutureTask futureTask : futureTasks) {
            total.add((Integer) futureTask.get());
        }

    }
}
